package com.sky.service.impl;

import com.github.yulichang.interfaces.MPJBaseJoin;
import com.github.yulichang.query.MPJLambdaQueryWrapper;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.sky.entity.Dish;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.mapper.SetmealMapper;
import com.sky.service.ISetmealService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sky.vo.DishItemVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 套餐 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-07-22
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class SetmealServiceImpl extends ServiceImpl<SetmealMapper, Setmeal> implements ISetmealService {
    private final SetmealMapper setmealMapper;


    /*
    * @Select("select sd.name, sd.copies, d.image, d.description " +
            "from setmeal_dish sd left join dish d on sd.dish_id = d.id " +
            "where sd.setmeal_id = #{setmealId}")
      */
    @Override
    public List<DishItemVO> getDishItemById(Long id) {
//        List<DishItemVO> dishItemVOS = setmealMapper.selectJoinList(DishItemVO.class,
//                new MPJLambdaWrapper<Setmeal>()
//                        .select(DishItemVO::getCopies, DishItemVO::getDescription, DishItemVO::getImage, DishItemVO::getName)
//                        .eq(SetmealDish::getSetmealId, id)
//                        .leftJoin(SetmealDish.class, SetmealDish::getDishId, Dish::getId));
        return setmealMapper.getDishItemBySetmealId(id);
        //return dishItemVOS;
    }
}
